﻿/**
 * 封装了一系列帮助方法，用来动态的配置编辑组件。
 */
Ext.define('Happy.metadata.EditorConfigFns', {
    singleton: true,

    comboBoxConfigFn: function (metadata, property, editorConfig) {
        Ext.apply(editorConfig, {
            xtype: 'happy-combobox',
            valueField: 'Id',
            displayField: property.foreignReference.metadata.data.summaryProperty,
            queryMode: 'local',
            storeConfig: {
                type: property.foreignReference.metadata.getStoreClassName(),
                url: property.foreignReference.metadata.getDefaultProxyConfig().api.fetch,
                autoLoad: true
            }
        });
    },

    treeComboBoxConfigFn: function (metadata, property, editorConfig) {
        Ext.apply(editorConfig, {
            xtype: 'happy-tree-combobox',
            valueField: 'Id',
            displayField: property.foreignReference.metadata.data.summaryProperty,
            queryMode: 'local',
            storeConfig: {
                type: property.foreignReference.metadata.getStoreClassName(),
                url: property.foreignReference.metadata.getDefaultProxyConfig().api.fetch,
                autoLoad: true
            }
        });
    }
});